package com.woniu.inlet.web;

import com.woniu.adapter.WarehousingAdapter;
import com.woniu.outlet.po.WarehousingApplication;
import com.woniu.util.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("Warehousing/")
@Api(tags = "入库controller")
public class WarehousingController {
    @Autowired
    private WarehousingAdapter warehousingAdapter;

    /** 确认已经入库 修改状态 防止另外一个列表查到
     * @param id
     * @return
     */
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id",value = "id",dataType = "int",example = "23",paramType = "query")
    })
    @PutMapping("updateStatus")
    @ApiOperation("修改入库申请状态")
    public ResponseResult updateStatus(Integer id){
        warehousingAdapter.updateStatus(id);
        return new ResponseResult(200, "修改入库申请状态成功");
    }

    /** 成品入库申请单
     * @param warehousingApplication
     * @return
     */
    @PostMapping("addWarehousing")
    @ApiOperation("新增入库申请")
    public ResponseResult addWarehousing(@RequestBody WarehousingApplication warehousingApplication){
        warehousingAdapter.addWarehousing(warehousingApplication);
        return new ResponseResult(200, "新增入库申请成功");
    }
}
